<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>注册</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../../layui-v2.6.8/layui/css/layui.css">
  <!--    <link rel="stylesheet" href="../../layui-v2.6.8/layui/layui.js" media="all">-->
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>

<!--<blockquote class="layui-elem-quote layui-text">-->
<!--    鉴于小伙伴的普遍反馈，先温馨提醒两个常见“问题”：1. <a href="/doc/base/faq.html#form" target="_blank">为什么select/checkbox/radio没显示？</a> 2. <a href="/doc/modules/form.html#render" target="_blank">动态添加的表单元素如何更新？</a>-->
<!--</blockquote>-->

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>注册</legend>
</fieldset>
<form class="layui-form" action="">
  <div class="layui-form-item">
    <label class="layui-form-label">姓名</label>
    <div class="layui-input-inline">
      <input type="text" id="cname" required lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">联系方式</label>
    <div class="layui-input-inline">
      <input type="text" id="cphone" required lay-verify="required" placeholder="请输入联系方式" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">账号</label>
    <div class="layui-input-inline">
      <input type="text" id="user_name" required lay-verify="required" placeholder="请输入账号" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">密码</label>
    <div class="layui-input-inline">
      <input type="text" id="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" onclick="insert_1()">注册</button>
    </div>
  </div>
</form>
<script src="../../layui-v2.6.8/layui/layui.js"></script>
<script>
  function insert_1(){
    var $ = layui.$;
    var cname =$("#cname").val();
    var cphone =$("#cphone").val();
    var user_name =$("#user_name").val();
    var password =$("#password").val();
    console.log(cname);
    var data ={
      "cname":cname,
      "cphone":cphone,
      "user_name":user_name,
      "password":password,
    }
    var layer=layui.layer;
    var url ="http://localhost:8080/add";
    $.ajax({
      url:url,
      type:"get",
      dataType:"json",
      async:true,
      // cache:false,
      data:data,
      success: function(data){
        console.log(data)
        if (data.code == 0) {

          layer.msg("添加成功", {icon: 6,time:1800});
          setTimeout(function (){
            // location.href = '../car/addCar.html';
          });
          window.location.href = 'CustomerIndex.html';
        } else {
          layer.msg("添加失败", {icon: 5});
        }
        return false;
      }
    });
  }
</script>
